#pragma once

struct Point
{
	Point() { X = 0; Y = 0; }
	Point(uint x, uint y) { X = x; Y = y; }
	uint X, Y;

	bool operator==(const Point & p)
	{
		return X == p.X && Y == p.Y; 
	}

	bool operator!=(const Point & p)
	{
		return !operator==(p);
	}
};

struct Rect
{
	Rect(uint x, uint y, uint width, uint height)
	{
		X = x;
		Y = y;
		Width = width;
		Height = height;
	}
	uint X, Y, Width, Height;
};

bool pointInRect(const Point & p, const Rect & rect);

namespace input
{
	

	struct KeyEvent
	{
		enum Key
		{
			KEY_SPACE,
			KEY_ENTER,
			KEY_BACKSPACE,
			KEY_SHIFT,
			KEY_ESCAPE,
			KEY_TAB,
			KEY_CR,
			KEY_LEFT,
			KEY_RIGHT,
			KEY_UP,
			KEY_DOWN,
			KEY_CHAR,
			KEY_UNKNOWN
		};

		Key PressedKey;
		TCHAR Char;
	};

	struct MouseEvent
	{
		enum TYPE
		{
			MOVE, L_DOWN, L_UP, M_DOWN, M_UP, R_DOWN, R_UP, WHEEL
		} Type;

		Point Pos;
		float WheelAmount;
	};

	struct Event
	{
		enum TYPE
		{
			MOUSE, KEY, OTHER
		} Type;

		KeyEvent KeyEv;
		MouseEvent MouseEv;
	};

	Event convertWindowsMsgToEvent(UINT msg, WPARAM wParam, LPARAM lParam);
	KeyEvent convert_WM_CHAR_ToKeyEvent(WPARAM wParam, LPARAM lParam);
	KeyEvent convert_WM_KEYDOWN_ToKeyEvent(WPARAM wParam, LPARAM lParam);
}